package sanlie2;

public class xianxingtancha {
    private int count=0;
    protected int[] arr=new int[11];
    final int IN=-12;


    public xianxingtancha(){
        for(int i=0;i<11;i++){
            arr[i]=IN;
        }
    }
    public xianxingtancha(int[] key){
        for(int i=0;i<11;i++){
            arr[i]=IN;
        }
        for(int j=0;j<arr.length;j++){
            Insert(key[j]);
        }
    }
    public void Insert(int key){
        int dizhi=hash(key);
        while(arr[dizhi]!=IN){
            dizhi=hash(dizhi+1);
        }
        arr[dizhi]=key;
        count++;
    }
    public int hash(int key){
        return key % 1;
    }
    public boolean search(int elem){
        int dizhi = hash(elem);
        while(this.arr[dizhi] != elem) {
            dizhi = hash(dizhi + 1);
            if(this.arr[dizhi] == IN || dizhi == hash(elem)) {
                return false;
            }
        }
        return true;
    }
    public String toString(){
        String result="";
        String result2="";
        for(int i=0;i<11;i++){
            result+=(arr[i]+" ");
            result2+=(i+"  ");
        }
        return (result2+"\n"+result);
    }
}
